package com.ywu.application.standard.thirdExec.exec.param.iml;

import com.ywu.common.gson.GsonUtils;
import com.ywu.application.standard.thirdExec.entity.YwuThirdExecParamEntity;
import com.ywu.application.standard.thirdExec.exec.param.YwuExecParamParse;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * @ClassName YwuExecParamParseObj
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/10/24 12:25
 * @Version 1.0
 **/
@Component
public class YwuExecParamParseObj implements YwuExecParamParse {
    private static final String OBJECT_PARAM_TYPE = "object";

    @Override
    public String paramType() {
        return OBJECT_PARAM_TYPE;
    }

    @Override
    public Object parse(YwuThirdExecParamEntity entity) {
        if (entity.getIsArray()) {
            return GsonUtils.deserializeList(entity.getValue(), HashMap.class);
        } else {
            return GsonUtils.deserialize(entity.getValue(), HashMap.class);
        }
    }
}
